using FluentAssertions;
using Sustainalytics.ScreeningTool.Synchronization.Caches;
using Sustainalytics.ScreeningTool.Synchronization.Entities;
using Xunit;

namespace Sustainalytics.ScreeningTool.Synchronization.Tests.Dictionaries.FieldDefinitionsCacheTests
{
    [Trait("Category", "Unit")]
    public class ContainsFieldWithValueFromParent_Should
    {
        private const string Key = "x";

        private readonly FieldDefinition FieldHasOwnValue = new FieldDefinition() { HasOwnValue = true };
        private readonly FieldDefinition FieldDoesntHaveOwnValue = new FieldDefinition() { HasOwnValue = false };

        [Fact]
        public void return_false_when_key_is_not_found()
            => new FieldDefinitionsCache().ContainsFieldWithValueFromParent(Key).Should().Be(false);

        [Fact]
        public void return_false_when_key_is_found_and_field_has_own_value()
            => new FieldDefinitionsCache { { Key, FieldHasOwnValue } }.ContainsFieldWithValueFromParent(Key).Should().Be(false);

        [Fact]
        public void return_true_when_key_is_found_and_field_doesnt_have_own_value()
            => new FieldDefinitionsCache { { Key, FieldDoesntHaveOwnValue } }.ContainsFieldWithValueFromParent(Key).Should().Be(true);
    }
}
